package cn.wolfcode.result;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult<T> {

    private int code;
    private String msg;
    private boolean success;
    private T data;

    public static <T> JsonResult success(T data){
        JsonResult jsonResult = new JsonResult();
        jsonResult.setSuccess(true);
        jsonResult.setData(data);
        return jsonResult;
    }

    public static <T> JsonResult error(String msg){
        JsonResult jsonResult = new JsonResult();
        jsonResult.setSuccess(false);
        jsonResult.setMsg(msg);
        return jsonResult;
    }
}
